package study.domain.blog;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import lombok.Data;
import study.domain.user.User;

import com.barney.support.domain.HasCreatedDate;
import com.barney.support.jpa.CreatedDateListener;

@Entity(name = "friends")
@Data
@EntityListeners(CreatedDateListener.class)
public class Friend implements Serializable, HasCreatedDate {

	private static final long serialVersionUID = 6310801089957844031L;

	@EmbeddedId
	private FriendId id;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(nullable = false, updatable = false)
	private Date createdDate;

	public Friend() {

	}

	public Friend(Long userId, Long friendId) {
		this(new FriendId(userId, friendId));
	}

	public Friend(User user, User friend) {
		this(new FriendId(user, friend));
	}

	public Friend(FriendId id) {
		this.id = id;
	}
}
